#ifndef FILEDB_H
#define FILEDB_H

#include <QObject>
#include <QVector>

namespace seven
{
	class PathTable;
	class FileTable;
}


class SEVEN_Export FileDB : public QObject
{
	Q_OBJECT

public:
	FileDB();
	~FileDB();

	bool GenerateFileDB(const QString& path);

	struct FileIntoItem
	{
		QString filename;
		qint32 pathId;
		qint64 size;
	};
	typedef QVector<QString> PathInfoTableType;
	typedef QVector<FileIntoItem> FileInfoTableType;

	const PathInfoTableType& GetPathInfoTable();
	const FileInfoTableType& GetFileInfoTable();

	void SetPathTable(const seven::PathTable* table);
	void SetFileTable(const seven::FileTable* table);

	void GetPathTable(seven::PathTable * table);
	void GetFileTable(seven::FileTable * table);


	QString GetFileRelativePath(int fileId);
	QString GetFilePath(int fileId);

	bool CreateFile(int fileId);
	bool CreateDir(int pathId);
	bool CreateDirs();
	int GetFileSize(int fileId);
	bool Write(int fileId,int begin,const char* buff,int size);
	void SetPath(QString path);

protected:
	void ParsePath(const QString& path, QString relativePath);

private:
	PathInfoTableType pathDB;
	FileInfoTableType fileDB;
	QString rootDir;
};

#endif // FILEDB_H
